package com.store.app.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.EditText;

/**
 * Created by Administrator on 2016/12/23.
 */
public class LastInputEditText extends EditText {

    public LastInputEditText(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public LastInputEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LastInputEditText(Context context) {
        super(context);
    }

    @Override
    protected void onSelectionChanged(int selStart, int selEnd) {
        super.onSelectionChanged(selStart, selEnd);
        Log.v("zyl", "selStart:" + selStart);
        Log.v("zyl", "selEnd:" + selEnd);
        //保证光标始终在最后面
        if(selStart ==0){
            setSelection(0);
        }
        else if (selStart == selEnd) {//防止不能多选
            setSelection(getText().length());
        }

    }
}
